const koa = require('koa');
const app = new koa();
const Router = require('@koa/router');
const router = new Router();
const {bodyParser} = require('@koa/bodyparser')



app.use(bodyParser())

//首页的接口
//关于首页的接口

router.get('/home' , (ctx,next) => {
    const {id} = ctx.query
    ctx.body = {
        code:200,
        msg:'success',
        data:{
            name:'张三',
            age:18,
            sex:'男'
        }
    }
})
router.post('/login' , (ctx) => {
            console.log(ctx.request.body);
            
     }
)


//生效路由
app.use(router.routes())

app.listen(3000 , () => {
    console.log('服务启动成功');
    
})